<script lang='ts'>
import { defineComponent, ref, watch } from 'vue';
import { SelectOptionKeyType } from '../remote-select/interface';
import { commonList } from '/@/api/org/code-list';
export default defineComponent({
    name: 'JxtechDictionarySelect'
})
</script>
<script lang='ts' setup>
const emit = defineEmits<{
    (e: 'update:value', value: string | Array<any> | undefined): void
}>()
const props = defineProps({
    /**
     * 绑定值
     */
    value: {
        type: [String, Array]
    },
    /**
     * 数据字典类型id
     */
    codeItemId: {
        type: String,
        required: true
    },
    size: {
        type: String,
        default: 'default'
    }
})
//设置双向绑定
const modelValue = ref(props.value);
watch(() => modelValue.value, val => {
    emit("update:value", val)
})
watch(() => props.value, val => {
    modelValue.value = val;
})

/**
 * 数据字典类型
 */
const selectValueType: SelectOptionKeyType = {
    labelKey: 'value',
    valueKey: 'key'
}
const loadData = () => commonList(props.codeItemId)
</script>
<template>
    <jxtech-remote-select
        style="width: 100%;"
        :size="props.size"
        :load-data="loadData"
        v-model:value="modelValue"
        :selectValueType="selectValueType"
    ></jxtech-remote-select>
</template>